﻿#include "choosemode.h"
#include<QPainter>
#include<QPushButton>
#include"mainwindow.h"
#include"mypushbutton.h"
#include<QTimer>
#include<QMainWindow>
#include<QMenuBar>

choosemode::choosemode(QWidget *parent) : QMainWindow(parent)
{
  //设置返回
    QMenuBar *bar = this->menuBar();
       this->setMenuBar(bar);
       QMenu * helpMenu = bar->addMenu("帮助");
       QAction *back = helpMenu->addAction("返回");//给菜单项下面再添加项目
       connect(back,&QAction::triggered,this,[=](){
          startFace=new start;
          this->hide();
          startFace->show();
       });
    //选择模式界面的配置
    this->setFixedSize(600,900);
    //设置图标
    this->setWindowIcon(QPixmap(":/pic/icon.png"));
    //设置标题
    this->setWindowTitle("模式选择");
    //设置模式按钮
    //人机
    MyPushButton*AI=new MyPushButton(":/pic/Button1.png","人机对战");
    AI->setParent(this);
    AI->move(0.5*this->width()-0.5*AI->width(),0.4*this->height());
    connect(AI,&MyPushButton::clicked,this,[=](){
        AI->zoom1();
        AI->zoom2();
        QTimer::singleShot(300,this,[=](){
            MainWindow * configWindow=new MainWindow;
           configWindow->show();
            this->close();
        });

    });
    //双人
    MyPushButton*TWO=new MyPushButton(":/pic/Button1.png","双人模式");
    TWO->setParent(this);
    TWO->move(0.5*this->width()-0.5*TWO->width(),0.4*this->height()+100);
    connect(TWO,&MyPushButton::clicked,this,[=](){
        TWO->zoom1();
        TWO->zoom2();
        QTimer::singleShot(300,this,[=](){
            MainWindow * configWindow=new MainWindow;
                        configWindow->changeType();
                       configWindow->show();
                        this->close();
        });

    });
}

void choosemode::paintEvent(QPaintEvent *){
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/pic/tachibanakanade2.png");
    painter.drawPixmap(0,0,pix.width(),pix.height(),pix);
}
